//
//  ZZQLiveHandler.m
//  zzqKanBoKe
//
//  Created by ben on 17/2/9.
//  Copyright © 2017年 张增强. All rights reserved.
//

#import "ZZQLiveHandler.h"
#import "HttpTool.h"
#import "ZZQLive.h"
#import "ZZQLocationManager.h"

@implementation ZZQLiveHandler

+ (void)executeGetHotLiveTaskWithSuccess:(SuccessBlock)success failed:(FailedBlock)failed{
    [HttpTool getWithPath:API_LiveGetTop params:nil success:^(id json) {
        if([json[@"dm_error"] integerValue]){
            failed(json);
        }else{
            NSArray * lives = [ZZQLive mj_objectArrayWithKeyValuesArray:json[@"lives"]];
            success(lives);
        }
        
    } failure:^(NSError *error) {
        failed(error);
    }];
}

+ (void)executeGetNearLiveTaskWithSuccess:(SuccessBlock)success failed:(FailedBlock)failed{
    ZZQLocationManager * manager = [ZZQLocationManager sharedManager];
    NSDictionary * params = @{@"uid":@"85149891", @"latitude":manager.lat, @"longitude":manager.lon};
    [HttpTool getWithPath:API_NearLocation params:params success:^(id json) {
        if([json[@"dm_error"] integerValue]){
            failed(json);
        }else{
            NSArray * lives = [ZZQLive mj_objectArrayWithKeyValuesArray:json[@"lives"]];
            success(lives);
        }
    } failure:^(NSError *error) {
        failed(error);
    }];
}

@end
